%{
int markers=1;
char *seperator="";
%}
ws [ \t]+
z {ws}?([0-9]*[.])?[0-9]+{ws}[0-9]+{ws}

plosive p|b|t|d|k|g
affricate pf|ts|tS|dZ
fricative f|v|s|z|S|Z|C|j|x|h
nasal N|m|n
liquid l|R
consonant {plosive}|{affricate}|{fricative}|{nasal}|{liquid}
shortvowel I|E|a|O|U|Y|9
longvowel i:|e:|E:|a:|o:|u:|y:|2:
diphtong aI|aU|OY|E6|I6|O6|U6|Y6|a6|2:6|E:6|a:6|e:6|i:6|o:6|u:6|y:6
schwa @|6
vowel {shortvowel}|{longvowel}|{diphtong}|{schwa}
marker \[|\]|\"

%%

^(signal(.*\n)*)?\#{ws}?\n  ECHO; /* printout header */
{z}                ECHO; /* printout time */
\<P\>              printf("pause%s",seperator);
\<A\>              printf("breath%s",seperator);
\<[^>]*\>          printf("extra_%s%s",yytext,seperator);
{plosive}          printf("pc_%s%s",yytext,seperator);
 /*{affricate}        printf("ac_%s%s",yytext,seperator);*/
{fricative}        printf("fc_%s%s",yytext,seperator);
{nasal}            printf("nc_%s%s",yytext,seperator);
{liquid}           printf("lc_%s%s",yytext,seperator);
r                  printf("lc_R%s",seperator);           /* this is just for convenience... */
{shortvowel}       printf("kv_%s%s",yytext,seperator);
{longvowel}        printf("lv_%s%s",yytext,seperator);
{diphtong}         printf("dv_%s%s",yytext,seperator);
{schwa}            printf("sv_%s%s",yytext,seperator);
 /*(A|O|\{|9)~:?      printf("nv_%s%s",yytext,seperator);*/
 /*={consonant}       printf("sc_%s%s",yytext,seperator);*/
\[                 {if (markers==1) {
                      printf("SyllableStart%s",seperator);}}
\]                 {if (markers==1) {
                      printf("SyllableEnd%s",seperator);}}
\"                 {if (markers==1) {
                      printf("WordAccent%s",seperator);}}
\#                 {if (markers==1) {
                      printf("WordBoundary%s",seperator);}}
%%
main(argc, argv)
int argc;
char **argv;
{
  int i;

  ++argv; --argc; /* skip over program name */
  if((argc>0)&&(strcmp(argv[0],"-s")==0)) {seperator=" "; ++argv; --argc;}
  if((argc>0)&&(strcmp(argv[0],"-n")==0)) {seperator="\n"; ++argv; --argc;}
  if((argc>0)&&(strcmp(argv[0],"-p")==0)) {markers=0; ++argv; --argc;}

  if(argc>0){
    for(i=0; i<argc; i++){

      yyin = fopen(argv[i],"r");
      if (yyin==NULL) 
        fprintf(stderr,"could not open %s --- skipped.\n",argv[i]);
      else {
        yylex();
      }
    }
  } else {
    yyin=stdin;
    yylex();
  }
}
